import request from '@/utils/request'

// 登录接口
export const userLoginService = ({ username, password }) =>
  request.post(
    '/auth/form/login',
    {
      username,
      password
    },
    {
      headers: {
        'content-type': 'application/x-www-form-urlencoded'
      }
    }
  )

export const userGetInfoService = () => request.get('auth/userinfo')

export const userUpdateInfoService = ({ userName }) =>
  request.put('auth/userinfo', null, {
    params: {
      userName
    }
  })

export const userUploadAvatarService = (avatar) => request.post('auth/avatar', avatar)

export const userUpdatePassService = ({ newPwd, oldPwd }) =>
  request.put('auth/pwd', { newPwd, oldPwd })
